﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ControlsLib;
using System.Linq.Expressions;
using GestionePolveri2.DAL;
using FrameworkLib.Filters;

namespace GestionePolveriLib.BL.Reports
{
    public class Filter512 : FilterBase<Movimenti>, IFilterBase
    {
        public Guid Operatore { get; set; }

        public Filter512()
        {

        }

        public override Expression<Func<Movimenti, bool>> SetUpFilter()
        {
            Expression<Func<Movimenti, bool>> retValue = null;

            if (this.Operatore == Guid.Empty)
            {
                retValue = x => ((x.DataMovimento >= this.PeriodFrom) && (x.DataMovimento <= this.PeriodTo));
            }
            else
            {
                retValue = x => (((x.DataMovimento >= this.PeriodFrom) && (x.DataMovimento <= this.PeriodTo)) &&
                                  (x.IDOperatore == this.Operatore));
            }

            return retValue;
        }

        //public override Func<Report512, bool> SetUpFilter(Action expression)
        //{

        //    return null; //new Func<Report512, bool>((((item.DataMovimento >= this.PeriodFrom) && (item.DataMovimento <= this.PeriodTo)));
        //}



        //public static Func<T, bool> BuildEqFuncFor<T>(string prop, object val)
        //{
        //    return ((t => t.GetType().InvokeMember(prop, System.Reflection.BindingFlags.GetProperty, null, t, null) == val) 
        //        (t => t.GetType().InvokeMember(prop, System.Reflection.BindingFlags.GetProperty, null, t, null) == val));
        //}
    }
}
